
package cn.klandor.picasa.util;

import java.io.File;
import java.io.FilenameFilter;

import javax.swing.filechooser.FileFilter;

public class ImageFileFilter extends FileFilter implements FilenameFilter{

	public String getDescription() {
		return "Image Files (*.jpg, *.png, *.gif, *.bmp)";
	}

	public boolean accept(File f) {
		if (f.isFile()) {
			return accept(f.getParentFile(), f.getName());
		} else if (f.isDirectory()) {
			return true;
		}
		return false;
	}

	public boolean accept(File dir, String name) {
		name = name.toLowerCase();
		return ( name.endsWith("jpg") || name.endsWith("jpeg") || name.endsWith("png") ||
		name.endsWith("gif") || name.endsWith("bmp") );
	}
	
}
